/*************************************************************************
	> File Name: EP22.cpp
	> Author: 
	> Mail: 
	> Created Time: 
 ************************************************************************/
#include <iostream>
#include <algorithm>
#include <string>
#include "./names.txt"
using namespace std;

int calc(const string &str, int n) {
    int sum = 0;
    for (int i = 0; i < str.size(); i++) {
        sum += (str[i] - 'A' + 1);
    }
    return sum * n;
}

int main() {
    int n = sizeof(names) / sizeof(names[0]);
    cout << n << endl;
    sort(names, names + n);
    int sum = 0;
    for (int i = 0; i < n; i++) {
        sum += calc(names[i], i + 1);
    }
    cout << sum << endl;
    return 0;
}
